package logic

import (
	"common/model"
	"context"
	"fmt"
	order "order_srv/proto"
)

func (o *OrderServer) UpdateOrderStatus(ctx context.Context, req *order.UpdateOrderStatusRequest) (*order.UpdateOrderStatusResponse, error) {
	var orderInfo model.Order
	err := orderInfo.GetOrderInfoByOrderId(req.OrderId)
	if err != nil {
		fmt.Println("test 0421")
		return nil, err
	}
	fmt.Println("test 0421 : 16.09")
	err = orderInfo.UpdateStatusByOrderId(req.OrderId, int(req.Status))
	if err != nil {
		return nil, err
	}
	return &order.UpdateOrderStatusResponse{
		UserId: int64(orderInfo.UserId),
	}, nil
}
